#ifndef CAMERAWIDGET_H
#define CAMERAWIDGET_H

#include <QWidget>
#include <QCamera>
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QMediaRecorder>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>

class CameraWidget : public QWidget
{
    Q_OBJECT
public:
    explicit CameraWidget(QWidget *parent = nullptr);
    ~CameraWidget();
    
private slots:
    void onCaptureButtonClicked();
    void onRecordButtonClicked();
    void onImageCaptured(int id, const QImage &preview);
    void updateStatus(const QString &status);
    void onError(QCamera::Error error);
    
private:
    QCamera *m_camera;             // 摄像头设备
    QCameraViewfinder *m_viewfinder; // 摄像头取景器
    QCameraImageCapture *m_imageCapture; // 图像捕获
    QMediaRecorder *m_mediaRecorder; // 视频录制
    QPushButton *m_captureButton;  // 拍照按钮
    QPushButton *m_recordButton;   // 录制按钮
    QLabel *m_statusLabel;         // 状态标签
    bool m_isRecording;            // 录制状态
};

#endif // CAMERAWIDGET_H
